package com.zzty.common;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

public class LoginEmailSend {
    public String sendEmail(String newEmail) {
        String result = "success";
        String body = "欢迎加入自在天原！";
        System.out.println("send email begin");
        HtmlEmail email = new HtmlEmail();

        email.setHostName("smtp.163.com"); // 设定smtp服务器
        email.setAuthentication("xiaopang_wu@163.com", "wzy19960620"); // 设定smtp服务器的认证资料信息
        try {
            email.addTo(newEmail, "Test"); // 设定收件人
            email.setFrom("xiaopang_wu@163.com", "吴振宇");
            email.setSubject("Welcome!");
            email.setCharset("UTF-8");
            email.setHtmlMsg("<html><h1>" + body + "</h1></html>");
            email.send();
        } catch (EmailException e) {
            e.printStackTrace();
        }

        System.out.println("end");
        return result;
    }
}
